﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NS_DBOP;

public partial class Flow_FlowStep : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Bind();
        }
    }

    public void Bind()
    {
        
        DataSet ds = new DBoperate().ExecuteQuery("select * from FlowStep where FlowID="+Convert.ToInt32(Request.QueryString["id"]), 0, 0, "table1");
        this.GridView1.DataSource = ds.Tables[0];
        this.GridView1.DataBind();
    }
    protected void btnStep_Click(object sender, EventArgs e)
    {
        Response.Write("<script language=javascript>window.location.href='NewStep.aspx?flid="+Request.QueryString["id"]+"'</script>");
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string strid = this.GridView1.DataKeys[e.RowIndex].Values.ToString();
        int delPerson = new DBoperate().ExecuteUpdate("delete from FlowStepPerson where StepID=" + strid);
        int result = new DBoperate().ExecuteUpdate("delete from FlowStep where ID=" + strid);
        if (result > 0)
        {
            Response.Write("<script language=javascrip>alert('删除成功！')</script>");
        }
        else
        {
            Response.Write("<script language=javascrip>alert('删除失败！')</script>");
        }
    }

    public string getAction(string id)
    {
        string action = new DBoperate().ExecuteScalar("select Name from FlowAction where ID=" + id).ToString();
        return action;
    }

    public string getPerson(string id)
    {
        string person = null;
        string strSql = "select Name from Employee where Employeeid in (select UserID from FlowStepPerson where StepID=" +Convert.ToInt32(id) + ")";
        DataSet ds = new DBoperate().ExecuteQuery(strSql, 0, 0, "per");
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            person += dr["Name"].ToString();
            person += ";";
        }
        return person;
    }
}
